<?php
/**
 * Sites Model
 *
 * PHP Version 5
 *
 * @package    Ecga
 * @subpackage Models
 * @author     FarmerLi <lixu_01@126.com>
 * @copyright  2010 Xingchangxinda Inc.
 * @version    SVN:$Id: projects.php 3051 2011-01-11 13:06:18Z sunbo $
 */

namespace Project\Apps\Ecga\Models;

use \Project\Models\Abstraction\Ecga\skuSiteUrls as bizSkuSiteUrls;

/**
 * Sites Model
 *
 * PHP version 5
 *
 * @package   Ecga
 * @author    FarmerLi <lixu_01@126.com>
 * @copyright 2010 Xingchangxinda Inc.
 * @version   Release: 0.1
 */
class SkuSiteUrls extends bizSkuSiteUrls
{
	/**
     * 获取指定SKU的渠道地址
     *
     * @param string $sku sku
     * 
     * @author Farmer.Li <lixu_01@126.com>
     * @return array
     */
    public function getBySKU($sku)
    {
        $items = $this->select()
        	->where('sku', '=', $sku)
        	->fetch();
        $items = iterator_to_array($items);
        $result = array();
        foreach ($items as $value) {
        	$result[$value->siteId] = $value;
        }
        return $result;
    }
    
    /**
     * 获取指定SKU指定渠道地址
     * 
     * @param string $sku    sku
     * @param int    $siteId 渠道ID
     * 
     * @return Entity
     */
    public function getBySKUAndSiteId($sku, $siteId)
    {
        return $this->select()
            ->where('sku', '=', $sku)
            ->where('siteId', '=', $siteId)
            ->fetch()
            ->current();
    }
}